package com.leave.servlet;

import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.leave.entity.Apply;
import com.leave.service.ApproveService;
import com.leave.util.BaseServlet;

public class TeacherApproveServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private ApproveService approveService = new ApproveService();

	public String Show_All_Apply_list(HttpServletRequest req, HttpServletResponse resp) throws SQLException {
		List<Apply> approve = (List<Apply>) approveService.show_all_approve(0);// 0表示待审核由班主任审批
		// 将获取到的记录保存到session中
		req.getSession().setAttribute("approve_list",approve);
		return "/WEB-INF/jsp/teacher/apply_list.jsp";

	}
	
	public String Agree_Approve(HttpServletRequest req, HttpServletResponse resp) throws SQLException {
		String aid = req.getParameter("aid");
		approveService.agree_approve(2, Integer.parseInt(aid));
		return "/WEB-INF/jsp/teacher/teacher.jsp";

	}
	
	public String Reject_Approve(HttpServletRequest req, HttpServletResponse resp) throws SQLException {
		String aid = req.getParameter("aid");
		approveService.agree_approve(1, Integer.parseInt(aid));
		return "/WEB-INF/jsp/teacher/teacher.jsp";

	}

}
